<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加印章</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="Shortcut Icon" href="cachet.ico">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
    <script src="/asset/js/common.js"></script>
</head>
<body >
<div class="alert_bigbox">

	<form class="layui-form">
		
		 <div class="layui-form-item">
              <label for="companyId" class="layui-form-label">
                  <span class="x-red">*</span>公司名称
              </label>
              <div class="layui-input-inline" style="width: 300px;">
                  <select name="companyId" lay-verify="companyId" lay-search="">
                  	<option value="">输入关键字搜索</option>
              		<#list companys as item>
              		<option value="${item.companyId}">${item.companyName}</option>
              		</#list>
                  </select>
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
	
          <div class="layui-form-item">
              <label for="devicesId" class="layui-form-label">
                  <span class="x-red">*</span>设备编号
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="devicesId" name="devicesId" required="" lay-verify="username" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="model" class="layui-form-label">
                  <span class="x-red">*</span>设备型号
              </label>
              <div class="layui-input-inline">
                  <select name="model" lay-filter="aihao">
                    <option value="v1.0" selected="">v1.0</option>
                    <option value="v2.0">v2.0</option>
                    <option value="v3.0">v3.0</option>
                  </select>
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
          
          
          <div class="layui-form-item">
              <label for="produceDate" class="layui-form-label">
                  <span class="x-red">*</span>出厂日期
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="produceDate" name="produceDate" required="" lay-verify="produceDate" autocomplete="off" class="layui-input dateinput">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="expireDate" class="layui-form-label">
                  <span class="x-red">*</span>失效日期
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="expireDate" name="expireDate" required="" lay-verify="expireDate" autocomplete="off" class="layui-input dateinput">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*失效日期设定后，时间到期会自动失效</span>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="expireDate" class="layui-form-label">
                  <span class="x-red">*</span>是否启用
              </label>
              <div class="layui-input-inline">
                  <input type="checkbox" name="isActivate" value="Y" lay-skin="switch" lay-text="禁用|启用" checked>
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*兼职用印章将无法使用</span>
              </div>
          </div>
          
          
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">增加</button>
          </div>
      </form>

</div>

    <script>
        layui.use(['form','layer','laydate'], function(){
            $ = layui.jquery;
          var form = layui.form,layer = layui.layer,laydate = layui.laydate;
          
          laydate.render({
		    elem: '.dateinput' //指定元素
		  });
        
          //自定义验证规则
          form.verify({
            username: function(value){
              if(value.length < 5){
                return '登陆账户至少得5个字符啊';
              }
            }
            ,password: [/(.+){6,12}$/, '密码必须6到12位']
            ,repassword: function(value){
                if($('#password').val()!=value){
                    return '两次密码不一致';
                }
            }
          });

          //监听提交
          form.on('submit(add)', function(data){
            $.ajax({
      			type:"POST", 
      			url:"/admin/devices/create.htm",
      			data:data.field,
      			success:function(result) {
		      
		      		if(result.code=='1'){
		      			layer.alert("增加成功", {icon: 6},function () {
			                // 获得frame索引
			                 window.parent.location.reload();
			                var index = parent.layer.getFrameIndex(window.name);
			                //关闭当前frame
			                parent.layer.close(index);
			            });
		      		}else{
		      		 	layer.msg(result.msg);
		      		}
		      
		    	 	} 
		    }); 
            
            return false;
          });
          
        });
    </script>

</body>
</html>